#include"Map.h"
#include<iostream>
#include<iomanip>
#include<fstream>
using namespace std;
CMap ::CMap(int level)
{
	switch(level)
	{
	case 0: file="Map\\Menu.MAP";break;
	case 1: file="Map\\LEVEL1.MAP";break;
	case 2: file="Map\\LEVEL2.MAP";break;
	}
}
void CMap::LoadMap()
{
	ifstream inFile;
	int nObject,id,kind,x,y,ow,oh;
	inFile.open(file);
	inFile>>width;
	inFile>>height;
	quadtree= new QuadTree(width,height);
	inFile>>nObject;
		Object object;
	for(int i=0;i<nObject;i++)
	{	
		inFile>>id;
		object.id=id;
		inFile>>kind;
		object.kind=kind;
		inFile>>x;
		object.x=x;
		inFile>>y;
		object.y=y;
		inFile>>ow;
		object.width=ow;
		inFile>>oh;
		object.height=oh;
		quadtree->AddNode(quadtree->root,object);
	}
		inFile.close();
	
	
}
void CMap::EmptyQuadTree()
{
	quadtree->Empty(quadtree->root);
}
void CMap::GetObjectFromQuadTree(LIST &list,RECT screen)
{
	quadtree->getObject(quadtree->root,list,screen);
}
int CMap::CollisionWithStaticObject(RECT marioRect)
{
	int kq;
	kq=quadtree->CollisionList(quadtree->root,marioRect);
	return kq;
}
